/**
 * 为啥要弄个一模一样的index2而不用同一套组件.....
 * 签署完生成合同的时候会莫名其妙出现合同加载不出来的bug
 * 出此下策来解决这个bug
 */

import Taro, { Component } from "@tarojs/taro";
import PageLoad from "../PageLoading";
import Pdfh5 from "pdfh5";
import "pdfh5/css/pdfh5.css";
class Pdf extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: true
    };
  }

  checkRefresh() {
    const pdf = document.getElementById("pdfList");
  }
  componentDidMount() {
    const that = this;

    //实例化
    this.pdfh5 = new Pdfh5("#pdfList2", {
      pdfurl: this.props.src
    });
    //监听完成事件
    this.pdfh5.on("complete", function(status, msg, time) {
      that.setState({
        loading: false
      });
      console.log(
        "状态：" +
          status +
          "，信息：" +
          msg +
          "，耗时：" +
          time +
          "毫秒，总页数：" +
          this.totalNum
      );
    });
  }

  render() {
    return (
      <div>
        {this.state.loading ? <PageLoad /> : null}
        <div id="pdfList2" style={{ height: "90vh" }}></div>;
      </div>
    );
  }
}
export default Pdf;
